package com.ylstm.controller;

import com.ylstm.pojo.Customer;
import com.ylstm.service.CustomerService;
import com.ylstm.utils.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName CustomerController
 * @Description TODO
 * @date 2022/8/3 10:01
 * @Version 1.0
 * 会员管理后台
 */
@RestController
@RequestMapping("/vip")
public class CustomerController {
    @Autowired
    CustomerService customerService;
    /*查询所有会员*/
    @RequestMapping("/selectAll")
    public ResultMessage seleAllVip(){
        ResultMessage resultMessage = customerService.selectAllVip();
        return resultMessage;
    }
    /*删除会员*/
    @RequestMapping("/delete")
    public ResultMessage deleteVip(Integer id){
        System.out.println(id);

        ResultMessage resultMessage = customerService.deleteVip(id);
       return resultMessage;
    }
    /*查询单个会员*/
    @RequestMapping("/selectOne")
    public ResultMessage selectOneVip(Integer id){
        ResultMessage resultMessage = customerService.selectOneVip(id);
        return resultMessage;
    }

    /*增加修改会员信息*/
    @ResponseBody
    @RequestMapping("/editor")
    public ResultMessage editorVip(@RequestBody Customer customer){
        ResultMessage resultMessage = customerService.editorVip(customer);
        System.out.println(resultMessage);
        return resultMessage;
    }

    /*模糊查询*/
    @RequestMapping("/search")
    public  ResultMessage searchVip(String code){
        System.out.println(code);
        ResultMessage resultMessage = customerService.searchVip(code);
        return  resultMessage;
    }
}
